In [6]:
import random #You use random import to shuffle the cards randomly, which is used throughout the program.

#The basic functions of the game, Deck of Cards is below:
def game(p_card, c_card): #Defining variable of game to play of the cards, which is player and computer.
    p_levels = levels.index(p_card[0]) #These levels are ranks and chooses which cards are which for the player and if there is no more left.
    c_levels = levels.index(c_card[0]) #These levels are the type of cards and are for the computer and to check if there are cards left. 
    if p_levels > c_levels: #The player levels are better than the computers.
        return "Player" #The players choice and the level of the card is returned shown.
    elif p_levels < c_levels: #The computers levels are better than the players card choice.
        return "Computer" #The computers choice and the level of the card is returned shown.
    else: #Another option from the choices
        return "Tie" #If the type of cards are the same it becomes a tie between the player and computer.
    
another_game = True #If the user wants to play another game at the end.

#The main details of the game, Deck of Cards is below:
while another_game: #This is a while loop that keeps going that lets the another games begin.

    suits = ("Hearts", "Spades","Diamonds", "Clubs") #The variable suits, which are the type of cards used and their names.
    levels = ("Ace","2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King") #The levels variable is used to show that each of the suits are the levels listed that are used as individual cards. 

    cards = [(level, suit) for suit in suits for level in levels] #This is the cards and are for the format for each which is the type of card and the level.
         
    random.shuffle(cards) #This function shuffles the cards when it is given to the player and computer.

    player = [cards.pop() for _ in range(5)] #This player gets 5 random cards and is chosen when it is shuffled.
    computer = [cards.pop() for _ in range(5)] #The computer also gets 5 cards that are randomly chosen.
    
    p_score = 0 #The players score is counted throughout the program. 
    c_score = 0 #The computers score is counted throughout the program. 


    for times in range(1,6): #This is the count of the amount of times the rounds are played. 
        print(f"The Round is {times}: ") #This is the rounds printed statement and the count.
        print("Player's hand: ", [card[0] + " of " + card[1] for card in player]) #This is the printed statement that prints the cards names and the shuffled.
        print("Computer's hand: ", ["Concealed"]*len(computer)) #This is the printed statement that showed the cards are concealed and are not shown to the player.
    
    
        p_choice = input("Get a card out of your deck: ") #This is the players choice out of the 5 cards and the user puts in 1, 2, 3, 4, or 5.
        p_card = player.pop(int(p_choice)-1) #This is the players cards and are subracted from the amount when the player chooses them.
    
    
        comp_choice = random.randint(0,len(computer)-1) #This is the computer choice and the computer also has 5 cards and are randomly chosen too.
        c_card = computer.pop(comp_choice) #This is the computers choice an is also subtracted when chosen.
    
        print("Player played: ", p_card[0] + " of " + p_card[1]) #This is the players cards formatted printed statement.
        print("Computer played: ", c_card[0] + " of " + c_card[1]) #This is the computers cards formatted printed statement.
    
    
        winner = game(p_card, c_card) #This chooses that game and who wins, which is between the player and the computer.
        if winner == "Player": #This gives the option if the player wins.
            p_score += 1 #The score of the player is added when the player wins the rounds.
            print("The Player has scored!!") #The printed statement when the player wins. 
        elif winner == "Computer": #If the computer wins, whih gives the option.
            c_score += 1 #The computers score increases when the computer wins.
            print("The Computer has scored!!") #The printed statement when the computer wins and is shown. 
        else: #The options if the two statements above are not true.
            print("IT's a TIE!") #The printed statement if the player and computer gets a tie in the game.

        print() #This statement prints the program and it shows how the program will run.
    
    
    print("The game has ended!") #A printed statement when the game is over and ends.
    print("The player has scored: ", p_score) #A printed statement of the players score throughout the game.
    print("The computer has scored: ", c_score) #The computers printed statement of their score. 

    another_game_choice = input("Do you want to play another game of Deck of Card? Yes or No:  ") #If the player wants to play another game of the Deck of Cards.
    if another_game_choice.lower() != "yes": #This is an if statement that shows if the players decision is yes and wants to play again.
        another_game = False #This shows that if the player does not want to play another game and wants to end it.
        print("Bye, Have a Good Day!! :)") #This is a printed statement that shows the player the program is ending
        
        
        
The Round is 1: 
Player's hand:  ['Jack of Spades', 'Queen of Hearts', 'Ace of Spades', '3 of Spades', '3 of Clubs']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  Jack of Spades
Computer played:  King of Spades
The Computer has scored!!

The Round is 2: 
Player's hand:  ['Queen of Hearts', 'Ace of Spades', '3 of Spades', '3 of Clubs']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  Queen of Hearts
Computer played:  10 of Spades
The Player has scored!!

The Round is 3: 
Player's hand:  ['Ace of Spades', '3 of Spades', '3 of Clubs']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  Ace of Spades
Computer played:  7 of Hearts
The Computer has scored!!

The Round is 4: 
Player's hand:  ['3 of Spades', '3 of Clubs']
Computer's hand:  ['Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  3 of Spades
Computer played:  Queen of Diamonds
The Computer has scored!!

The Round is 5: 
Player's hand:  ['3 of Clubs']
Computer's hand:  ['Concealed']
Get a card out of your deck: 1
Player played:  3 of Clubs
Computer played:  6 of Diamonds
The Computer has scored!!

The game has ended!
The player has scored:  1
The computer has scored:  4
Do you want to play another game of Deck of Card? Yes or No:  yes
The Round is 1: 
Player's hand:  ['10 of Hearts', '3 of Hearts', 'King of Spades', 'Queen of Spades', '9 of Spades']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  10 of Hearts
Computer played:  7 of Diamonds
The Player has scored!!

The Round is 2: 
Player's hand:  ['3 of Hearts', 'King of Spades', 'Queen of Spades', '9 of Spades']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  3 of Hearts
Computer played:  6 of Spades
The Computer has scored!!

The Round is 3: 
Player's hand:  ['King of Spades', 'Queen of Spades', '9 of Spades']
Computer's hand:  ['Concealed', 'Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  King of Spades
Computer played:  7 of Clubs
The Player has scored!!

The Round is 4: 
Player's hand:  ['Queen of Spades', '9 of Spades']
Computer's hand:  ['Concealed', 'Concealed']
Get a card out of your deck: 1
Player played:  Queen of Spades
Computer played:  4 of Clubs
The Player has scored!!

The Round is 5: 
Player's hand:  ['9 of Spades']
Computer's hand:  ['Concealed']
Get a card out of your deck: 1
Player played:  9 of Spades
Computer played:  4 of Diamonds
The Player has scored!!

The game has ended!
The player has scored:  4
The computer has scored:  1
Do you want to play another game of Deck of Card? Yes or No:  no
Bye, Have a Good Day!! :)
In [ ]:
import random #You use random import to shuffle the cards randomly, which is used throughout the program.
another_game = True #If the user wants to play another game at the end.
while another_game: #This is a while loop that keeps going that lets the another games begin.
    suits = ("Hearts", "Spades","Diamonds", "Clubs") #The variable suits, which are the type of cards used and their names.
    levels = ("Ace","2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King") #The levels variable is used to show that each of the suits are the levels listed that are used as individual cards. 

    def card(): #Defining the card variable that shows how the form of the card types would be.
        cards = [] #The card varible has a empty tuple that puts the card the player gets throughout the program.
        for suit in suits: #The form of the suits that shows there are for suit with each level.
            for level in levels: #each level is matched up with the suit
                cards.append(level + " of " + suit) #The cards are put into the tuple with the following form
        return cards

    def hand(cards):
        random.shuffle(cards)
        holder = cards[:5]
        return holder

    def switch(holder, kind):                            
        new = hand(cards)
        for form in kind:
            holder[form] = new.pop(0)
            return holder
        
    cards = card()
    holder = hand(cards)

    print("Your Hand: ")
    for things in holder:
        print(things)
    
    
    choice = input("Do you want to switch any of your cards? Yes or No: ")
    print("If Yes, the count of the cards begins from 0!!")

    if choice.lower() == "yes":
        num = 0    
        while num < 4:
            change = input("Which Cards? ")
            change_kind = [int(form) for form in change.split()]
    
            if change_kind == (0):
                break
    
            holder = switch(holder, change_kind)
            num += 1

    print(" Your final cards: ")
    for things in holder:
        print(things)

        
    another_game_choice = input("Do you want to play another game of Deck of Card? Yes or No:  ") #If the player wants to play another game of the Deck of Cards.
    if another_game_choice.lower() != "yes": #This is an if statement that shows if the players decision is yes and wants to play again.
        another_game = False #This shows that if the player does not want to play another game and wants to end it.
        print("Bye, Have a Good Day!! :)") #This is a printed statement that shows the player the program is ending
            
        
        
        
        
In [ ]:
 
In [ ]:
import random #You use random import to shuffle the cards randomly, which is used throughout the program.

def game(p_card, c_card): #Defining variable of game to play of the cards, which is player and computer.
    p_levels = levels.index(p_card[0]) #These levels are ranks and chooses which cards are which for the player.
    c_levels = levels.index(c_card[0]) #These levels are the type of cards and are for the computer. 
    if p_levels > c_levels: #The player levels are better than the computers.
        return "Player" #The players choice and the level of the card is returned shown.
    elif p_levels < c_levels: #The computers levels are better than the players card choice.
        return "Computer" #The computers choice and the level of the card is returned shown.
    else: #Another option from the choices
        return "Tie" #If the type of cards are the same it becomes a tie between the player and computer.
    
another_game = True #If the user wants to play another game at the end.

while another_game: #This is a while loop that keeps going that lets the another games begin.

    suits = ("Hearts", "Spades","Diamonds", "Clubs") #The variable suits, which are the type of cards used and their names.
    levels = ("Ace","2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King") #The levels variable is used to show that each of the suits are the levels listed that are used as individual cards. 

    cards = [(level, suit) for suit in suits for level in levels] #This is the cards and are for the format for each which is the type of card and the level.
         
    random.shuffle(cards) #This function shuffles the cards when it is given to the player and computer.

    player = [cards.pop() for _ in range(5)] #This player gets 5 random cards and is chosen when it is shuffled.
    computer = [cards.pop() for _ in range(5)] #The computer also gets 5 cards that are randomly chosen.
    
    p_score = 0 #The players score is counted throughout the program. 
    c_score = 0 #The computers score is counted throughout the program. 


    for times in range(1,6): #This is the count of the amount of times the rounds are played. 
        print(f"The Round is {times}: ") #This is the rounds printed statement and the count.
        print("Player's hand: ", [card[0] + " of " + card[1] for card in player]) #This is the printed statement that prints the cards names and the shuffled.
        print("Computer's hand: ", ["Concealed"]*len(computer)) #This is the printed statement that showed the cards are concealed and are not shown to the player.
    
    
        p_choice = input("Get a card out of your deck: ") #This is the players choice out of the 5 cards and the user puts in 1, 2, 3, 4, or 5.
        p_card = player.pop(int(p_choice)-1) #This is the players cards and are subracted from the amount when the player chooses them.
    
    
        comp_choice = random.randint(0,len(computer)-1) #This is the computer choice and the computer also has 5 cards and are randomly chosen too.
        c_card = computer.pop(comp_choice) #This is the computers choice an is also subtracted when chosen.
    
        print("Player played: ", p_card[0] + " of " + p_card[1]) #This is the players cards formatted printed statement.
        print("Computer played: ", c_card[0] + " of " + c_card[1]) #This is the computers cards formatted printed statement.
    
    
        win = game(p_card, c_card) #This chooses that game and who wins, which is between the player and the computer.
        if win == "Player": #This gives the option if the player wins.
            p_score += 1 #The score of the player is added when the player wins the rounds.
            print("Player WINS") #The printed statement when the player wins. 
        elif win == "Computer": #If the computer wins, whih gives the option.
            c_score += 1 #The computers score increases when the computer wins.
            print("Computer WINS") #The printed statement when the computer wins and is shown. 
        else: #The options if the two statements above are not true.
            print("TIE") #The printed statement if the player and computer gets a tie in the game.

        print() #This statement prints the program and it shows how the program will run.
    
    
    print("Game Over!") #A printed statement when the game is over and ends.
    print("Player wins: ", p_score) #A printed statement of the players score throughout the game.
    print("Computer wins: ", c_score) #The computers printed statement of their score. 

    another_game_choice = input("Do you want to play another game of Deck of Card? Yes or No:  ") #If the player wants to play another game of the Deck of Cards.
    if another_game_choice.lower() != "yes": #This is an if statement that shows if the players decision is yes and wants to play again.
        another_game = False #This shows that if the player does not want to play another game and wants to end it.
        print("Bye, Have a Good Day!! :)") #This is a printed statement that shows the player the program is ending